Skip to content

Add Environment Documentation for Virtual Environment Including Local Core Repository#4669

Open
SoulofAkuma wants to merge 6 commits into
open-telemetry:mainfrom
SoulofAkuma:add-devenv-documentation
Open

Add Environment Documentation for Virtual Environment Including Local Core Repository#4669
SoulofAkuma wants to merge 6 commits into
open-telemetry:mainfrom
SoulofAkuma:add-devenv-documentation

Conversation

@SoulofAkuma

Copy link
Copy Markdown

Description

This PR adds documentation and a script to make it easier to setup a local workspace that contains both the core python repository as well as this one. Using the documentation provided in CONTRIBUTING.md and having limited knowledge of uv, I found it challenging to troubleshoot issues that may be in the core or in the contrib repository.

I have now added documentation on how to manually modify the uv configuration in pyproject.toml to resolve these dependencies locally, as well as a script that scans the pyproject.toml files of both the core and the contrib repository. Specifically, the helper script detects all dependencies in the contrib's pyproject.toml which are not workspace dependencies, but which can be resolved via the core repository locally.

Unfortunately, to my knowledge it is not a feature in uv itself to combine two workspaces like this, hence the helper script and added documentation.

Fixes #4639

Type of change

Please delete options that are not relevant.

  • New feature/Documentation (non-breaking change which adds functionality)

How Has This Been Tested?

Simply clone the core repository and the contrib one locally and then run the script referencing the two pyproject.toml files.

Finally, replace the contrib's tool.uv.sources section in the pyproject.toml with the output of the script and run uv sync.

The environment that is being created should use local file references for any dependencies that are available in the core repositroy.

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated - documentation change and helper script only
  • Unit tests have not been added - documentation change and helper script only
  • Documentation has been updated

Please let me know if a changelog should still be added for this due to the added helper script.

@SoulofAkuma
SoulofAkuma requested a review from a team as a code owner June 7, 2026 17:16
@github-actions

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.
If you're still working on this, please add a comment or push new commits.

@github-actions github-actions Bot added the Stale label Jun 22, 2026

@emdneto emdneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments

Comment thread pyproject.toml
"opentelemetry-instrumentation",
"opentelemetry-distro",
"opentelemetry-test-utils",
"opentelemetry-exporter-otlp",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this change.

Comment thread CONTRIBUTING.md

This will create a virtual environment in the `.venv` directory and install all the necessary dependencies.

#### Virtual Environment Including Local Core Repository

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I usually do is the following:

from contrib -> uv sync and uv sync --project ../opentelemetry-python --active --inexact. It will replace the previously git installed deps from -core by using the local path. Do you think this can help?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @emdneto . So that is the way to do it... Well I will remove the script and update the markdown with this, thanks.

Have you had any experience with debugging using a virtual environment like this, for instance with vscode?
Are the python files the ones in the actual clone of your repo then or are they coming from the venv directory?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the python files the ones in the actual clone of your repo
This ⬆️

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emdneto yes, using the script to generate a tool.uv.sources section would then use the the local files in my actual clone instead of installing the package from a remote. But your command seems to achieve the same. I still have to get around to actually locally testing it though (what I put into the PR so far I've tested of course, not your command yet)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right, I ran your commands through now and I've gotten the following results (I'm using where it's pulling opentelemetry-api from as an example)

So having the contrib and core repo cloned in two different folders and running a simple uv sync in the contrib repo (without your arguments yet), pulls opentelemetry-api from github as expected:

Using CPython 3.12.13 interpreter at: /opt/python/3.12.13/bin/python3
Creating virtual environment at: .venv
Resolved 292 packages in 33ms
Installed 224 packages in 348ms
...
 + opentelemetry-api==1.44.0.dev0 (from git+https://github.com/open-telemetry/opentelemetry-python@9ffd585e2f5eb296e2c9e834887b382af0c18727#subdirectory=opentelemetry-api)
...

Running the command you mentioned uv sync --project ../opentelemetry-python --active --inexact after activating the environment source .venv/bin/activate gives me:

Resolved 88 packages in 13ms
Uninstalled 32 packages in 25ms
Installed 54 packages in 34ms
...
 - opentelemetry-api==1.44.0.dev0 (from git+https://github.com/open-telemetry/opentelemetry-python@9ffd585e2f5eb296e2c9e834887b382af0c18727#subdirectory=opentelemetry-api)
 + opentelemetry-api==1.42.0.dev0 (from file:///home/mallert2/workspace/otel/otel-python/opentelemetry-python/opentelemetry-api)
...

This looks good and it is now pulling in opentelemetry-api locally. It also changed a bunch of other dependency versions to what is in the uv.lock file of the core repository, but I guess that should be fine.

@github-actions github-actions Bot removed the Stale label Jun 23, 2026
@xrmx xrmx moved this to Reviewed PRs that need fixes in Python PR digest Jun 23, 2026
@github-actions

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.
If you're still working on this, please add a comment or push new commits.

@github-actions github-actions Bot added Stale and removed Stale labels Jul 16, 2026
@SoulofAkuma

Copy link
Copy Markdown
Author

@emdneto I reworked the entire PR now. It just mentions the uv command you pointed to in the CONTRIBUTING.md now, instead of the custom python script solution I assumed was necessary before. Could you re-review please?

@SoulofAkuma
SoulofAkuma requested a review from emdneto July 24, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Reviewed PRs that need fixes

Development

Successfully merging this pull request may close these issues.

Provide Documentation to Set Up Shared -contrib and sdk Workspace

3 participants